package com.buer.storage.controller;

import com.alibaba.fastjson.JSON;
import com.buer.storage.dao.AreaDao;
import com.buer.storage.entity.Area;
import com.buer.storage.otherDao.FormmainDao;
import com.buer.storage.otherEntity.FormmainDO;
import com.buer.storage.otherService.FormmainService;
import com.buer.storage.service.AreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2021/1/26.
 */
@RestController
@RequestMapping("/doubleSource")
@Api(value = "双数据源测试相关", description = "双数据源测试相关")
public class DoubleDataSourceController {
    @Autowired
    private AreaDao areaDao;

    @Autowired
    private AreaService areaService;

    @Autowired
    private FormmainDao formmainDao;

    @Autowired
    private FormmainService formmainService;


    @GetMapping("/get")
    @ApiOperation(value = "mysql数据源")
    public void get(){
     //   Map area = areaDao.getById(31);
        Area area1 = areaService.selectById(31);
    }

   /* @GetMapping("/get2")
    @ApiOperation(value = "sqlserver数据源")
    public FormmainDO get2(){
        BigDecimal id=new BigDecimal("-9130172737953312848");
        FormmainDO formmainDO = formmainDao.get(id);
        return formmainDO;
    }*/


    /*@GetMapping("/add")
    @ApiOperation(value = "sqlserver数据源添加测试")
    public void add(){
        BigDecimal id=new BigDecimal("1611653822075588905");
        FormmainDO formmainDO = formmainService.get(id);
        formmainDO.setID(CommonGeneratorUtil.generatorId());
        formmainDO.setStartDate(new Date());
        int save = formmainService.save(formmainDO);

        System.out.println("save状态："+save);

    }*/

   /* @GetMapping("/update")
    @ApiOperation(value = "sqlserver数据源更新测试")
    public void update(){
        BigDecimal id=new BigDecimal("1611654100517299835");
        FormmainDO formmainDO = formmainService.get(id);
        //formmainDO.setID(CommonGeneratorUtil.generatorId());
        formmainDO.setStartDate(new Date());
        int update = formmainService.update(formmainDO);

        System.out.println("update状态："+update);

    }*/

   /* @GetMapping("/delete")
    @ApiOperation(value = "sqlserver数据源删除测试")
    public void delete(){
        BigDecimal id=new BigDecimal("1611654100517299835");
        int remove = formmainService.remove(id);

        System.out.println("delete状态："+remove);

    }*/

    @GetMapping("/getFormmainByProdCode")
    @ApiOperation(value = "sqlserver数据源根据prodCode查询数据")
    public void getFormmainByProdCode(){
        Map<String,Object> map=new HashMap();
        map.put("field0004","ZB0023");
        FormmainDO one = formmainService.getOne(map);
        System.out.println("one："+ JSON.toJSONString(one));

    }

}
